#coding=utf-8

import os

from django.db import models
from django.contrib.auth.models import User
from django.conf import settings

class ImageManager(models.Manager):
	pass

class Image(models.Model):    
    PHOTO = 0
    AVATAR = 1
    user = models.ForeignKey(User)
    raw_file = models.TextField()
    type = models.IntegerField()
    created_time = models.DateTimeField(auto_now_add=True)
	
    objects = ImageManager()
	
    class Meta:
        verbose_name = u'图片'
        verbose_name_plural = u'图片列表'
        db_table = "t_image"    
        ordering = ["-created_time"]
        
    def get_url(self):
        return os.path.join(settings.IMAGE_UPLOAD_URL, self.raw_file)